#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 2e5 + 5;
using pll = pair<ll, ll>;

ll n, m;
ll primes[9] = {2, 3, 5, 7, 11, 13, 17, 19, 23};
pll ans;
void dfs(int i, int mx, pll pre) {
  if (i >= 9) return;
  ll p = 1;
  rep(j, 1, mx) {
    p *= primes[i];
    if (p * pre.first > n) break;
    pll now{p * pre.first, pre.second * (j + 1)};

    if (now.second > ans.second ||
        now.second == ans.second && now.first < ans.first)
      ans = now;
    dfs(i + 1, j, now);
  }
}
void solve() {
  dfs(0, 31, pll(1, 1));
  cout << ans.first;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  solve();

  return 0;
}